#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Setup configuration."""

import os
import platform

try:
  import setuptools
except ImportError:
  from ez_setup import use_setuptools
  use_setuptools()
  import setuptools

py_version = platform.python_version_tuple()
if py_version < ('2', '7') or py_version[0] == '3' and py_version < ('3', '4'):
  raise RuntimeError('Python version 2.7 or 3.4+ required')

user_home = os.getenv('HOME')

# In this setup does two things for us:
# 1. Install the py proto module.
# 2. Install the proto wrapper header files generated by pyclif_proto as data
#    file. This is done because building the dependent extension modules
#    (wrap_protos.clif in our case) needs these files available somewhere in the
#    include path.
# We should not ideally be needing #2. However, we need it currently as the
# #include directives in pyclif-generated files do not use the full path
# to the header files (relative to the project root).
setuptools.setup(
    name='pyclif_example_wrap_protos_deps',
    version='1.0',
    description='Python CLIF wrap_protos example deps',
    url='https://github.com/google/clif',
    author='CLIF authors',
    author_email='pyclif@googlegroups.com',
    install_requires=['enum34;python_version<"3.4"'],
    py_modules=['sample_pb2'],
    data_files=[
        (user_home + '/opt/clif/examples/wrap_protos/protos/',
         ['sample.pb.h', 'sample_pyclif.h']),
        ],
    )
